package com.bc.bcapi.service;

import com.bc.commoncore.util.CookieUtils;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.math.BigInteger;

import com.bc.bcapi.dao.T_Project_typeMapper;
import com.bc.bcmodel.domain.T_Project_typeModel;

/**
 * @Name T_Project_typeService * @Description TODO * @Author generation * @Date 2018/8/9 15:56:31 * @Version 1.0
 **/
@Service
public class T_Project_typeService {
    @Resource
    T_Project_typeMapper t_Project_typeMapper;

    /**
     * 保存单条数据     *      * @return
     */

    public int insert(T_Project_typeModel req) {
        return t_Project_typeMapper.insert(req);
    }

    /**
     * 批量增加数据     *      * @return
     */

    public int insertBatch(List<T_Project_typeModel> req) {
        return t_Project_typeMapper.insertBatch(req);
    }

    /**
     * 根据对象属性查找满足条件的第一条数据     *      * @return
     */

    public T_Project_typeModel findByNamedParam(T_Project_typeModel req) {
        return t_Project_typeMapper.findByNamedParam(req);
    }

    /**
     * 根据对象查询所有数据     *      * @return
     */

    public List<T_Project_typeModel> getAllList(T_Project_typeModel req) {
        req.setIsdel(0);
        return t_Project_typeMapper.findByNamedParamList(req);
    }

    /**
     * 根据对象查询所有分页数据     *      * @return
     */

    public PageInfo<T_Project_typeModel> getList(T_Project_typeModel req) {
        PageHelper.startPage(req.getPage_index(), req.getPage_size());
        req.setIsdel(0);
        List<T_Project_typeModel> list = t_Project_typeMapper.findByNamedParamList(req);
        return new PageInfo<T_Project_typeModel>(list);
    }

    /**
     * 更新指定对象     *      * @return
     */

    public int update(T_Project_typeModel req) {
        return t_Project_typeMapper.update(req);
    }

    /**
     * 删除指定数据     *      * @return
     */

    public int delete(BigInteger id) {
        return t_Project_typeMapper.delete(id);
    }

    /**
     * 根据条件统计数据量     *      * @return
     */

    public long count(T_Project_typeModel req) {
        return t_Project_typeMapper.count(req);
    }

    public List<T_Project_typeModel> getType(HttpServletRequest request) {
        String language = CookieUtils.getCookie(request, "local");
        List<T_Project_typeModel> list = null;
        if (StringUtils.isEmpty(language)) {
            language = "zh";
        }
        if (language.equals("zh")) {
            list = t_Project_typeMapper.getTypeZh();
        } else {
            list = t_Project_typeMapper.getTypeEn();
        }
        return list;
    }
}